import React, { Component } from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as actions from '../../actions/city'
import CityHeader from '../../component/Header'
import CurrentCity from './CurrentCity'
import HotCity from './HotCity'
class City extends Component {
    cityNameHandler(city){
        this.props.cityActions.setCity({
            cityName:city
        })
    }
    render() {
        return (
            <div>
                <CityHeader title="请选择城市"/>
                <CurrentCity city={this.props.city.cityName}/>
                <HotCity cityNameHandler={this.cityNameHandler.bind(this)}/>
            </div>
        );
    }
}

const mapStateToProps = (state) => {
    return {
        city:state.city
    }
}
const mapDispatchToProps = dispatch => {
    return {
        cityActions:bindActionCreators(actions,dispatch)
    }
}
export default connect(mapStateToProps,mapDispatchToProps)(City);